package com.aldobucchi.ds
{
	
	import flash.events.Event;



	/**
	 * 
	 * We provide one general event for all the data structures.
	 * Specialization occurs in the diff property ( more on this )
	 * 
	 * Some of the reasons we extracted the "Diff" from the "Event":
	 * <ul>
	 *   <li>
	 *       It makes sense to use a Diff in other contexts, not tied to events.
	 *       You could calculate the diff between two datastructures or apply a Diff to several data structures.
	 *   </li>
	 *   <li>
	 *		When an object gets clone()'d, the diff is just passed by reference instead of replicating
	 * 		all internal properties, as you now do with CollectionEvent.
	 *   </li>
	 * </ul>
	 * 
	 * 
	 * @author aldo.bucchi@gmail.com
	 * 
	 */
	public class DataStructureEvent extends Event
	{
		
		
		public static const CHANGE:String = "change";		


		private var _diff:DataStructureDiff;


		public function get diff( ):DataStructureDiff
		{
			return _diff;
		}



		public function DataStructureEvent( type:String, diff:DataStructureDiff, bubbles:Boolean=false, cancelable:Boolean=false)
		{
			
			super( type, bubbles, cancelable );
		
			_diff = diff;	
		
		}
		
		
		
		
		
		
		override public function clone():Event
		{
		
			return new DataStructureEvent( type, diff, bubbles, cancelable );
		
		}
		
		
		
	}

}